//
//  WBVistorView.swift
//  weiboNine
//
//  Created by 陈逸麒 on 2017/4/5.
//  Copyright © 2017年 chenyq. All rights reserved.
//

import UIKit

class WBVistorView: UIView {

    //大图标
    var iconImageView: UIImageView = UIImageView(imageName: "visitordiscover_feed_image_house")
    
    //圆圈
    var circleImageView: UIImageView = UIImageView(imageName: "visitordiscover_feed_image_smallicon")
    
    //遮罩视图
    var maskImageView: UIImageView = UIImageView(imageName: "visitordiscover_feed_mask_smallicon")
    
    //注册按钮
    var registButton: UIButton = UIButton(title: "注册", titleColor: UIColor.orange, bgImage: "common_button_white_disable", target: self as AnyObject, action: #selector(login))
    
    //登入按钮
    var loginButton: UIButton = UIButton(title: "登入", titleColor: UIColor.orange, bgImage: "common_button_white_disable", target: self as AnyObject, action: #selector(login))
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        setupUI()
        
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

}
// MARK: - 事件处理
extension WBVistorView {
    func login() {
        print("hello, world")
    }
}
// MARK: - 设置UI
extension WBVistorView{
    
    func setupUI(){
        
        //设置背景颜色
        self.backgroundColor = UIColor.rgbColor(r: 237, g: 237, b: 237)
        
        //添加控件
        addSubview(iconImageView)
        addSubview(circleImageView)
        addSubview(maskImageView)
        addSubview(loginButton)
        addSubview(registButton)
        
        //设置约束
        iconImageView.snp.makeConstraints { (make) in
            make.centerX.equalTo(self)
            make.centerY.equalTo(self).offset(-100)
        }
        
        circleImageView.snp.makeConstraints { (make) in
            make.centerX.equalTo(iconImageView)
            make.centerY.equalTo(iconImageView)
        }
        
        maskImageView.snp.makeConstraints { (make) in
            make.centerX.equalTo(iconImageView)
            make.centerY.equalTo(iconImageView).offset(40)
            make.left.right.equalTo(self)
        }
        
        registButton.snp.makeConstraints { (make) in
            make.left.equalTo(self).offset(70)
            make.bottom.equalTo(self).offset(-220)
            make.size.equalTo(CGSize(width: 90, height: 35))
        }
        
        loginButton.snp.makeConstraints { (make) in
            make.right.equalTo(self).offset(-70)
            make.bottom.equalTo(registButton)
            make.size.equalTo(CGSize(width: 90, height: 35))
        }
    }
    
}
